//
//  LBDataFactory.m
//  LvoeBeen_Imitation
//
//  Created by Mac on 17/2/18.
//  Copyright © 2017年 itcast. All rights reserved.
//

#import "LBDataFactory.h"
#import "LBHTTPClient.h"

@implementation LBDataFactory

+ (instancetype) sharedDataFactory {
    static LBDataFactory *dataFactory;
    
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        dataFactory = [LBDataFactory new];
    });
    return dataFactory;
}

#pragma mark
#pragma mark - 首页焦点数据
+ (void)loadHomePageFocusDataWithBlock:(void (^)(id,NSError *))dataBlock {
    
    [LBHTTPClient loadDataWithType:HttpTypePost urlString:@"focus.json.php" param:@{@"call":@1} progressBlock:nil SuccedBlock:^(NSURLSessionDataTask *task, id object) {
        dataBlock(object,nil);
    } failureBlock:^(NSURLSessionDataTask *task, NSError *error) {
        dataBlock(nil,error);
    }];
}

#pragma mark
#pragma mark - 新鲜热卖数据 firstSell
+ (void)loadFirstCellWithBlock:(void (^)(id,NSError *))dataBlock {
    [LBHTTPClient loadDataWithType:HttpTypePost urlString:@"firstSell.json.php" param:@{@"call":@2} progressBlock:nil SuccedBlock:^(NSURLSessionDataTask *task, id object) {
        dataBlock(object,nil);
    } failureBlock:^(NSURLSessionDataTask *task, NSError *error) {
        dataBlock(nil,error);
    }];
}

#pragma mark
#pragma mark - 程序启动广告
+ (void)loadAdvertiseWithBlock:(void (^)(id,NSError *))dataBlock {
    [LBHTTPClient loadDataWithType:HttpTypePost urlString:@"ad.json.php" param:@{@"call":@7} progressBlock:nil SuccedBlock:^(NSURLSessionDataTask *task, id object) {
        dataBlock(object,nil);
    } failureBlock:^(NSURLSessionDataTask *task, NSError *error) {
        dataBlock(nil,error);
    }];
}

#pragma mark
#pragma mark - 闪电超市数据
+ (void)loadLightSuperMarketWithBlock:(void (^)(id,NSError *))dataBlock {
    [LBHTTPClient loadDataWithType:HttpTypePost urlString:@"supermarket.json.php" param:@{@"call":@5} progressBlock:nil SuccedBlock:^(NSURLSessionDataTask *task, id object) {
        dataBlock(object,nil);
    } failureBlock:^(NSURLSessionDataTask *task, NSError *error) {
        dataBlock(nil,error);
    }];
}

#pragma mark
#pragma mark - 搜索关键词
+ (void)loadSearchKeywordWithBlock:(void (^)(id,NSError *))dataBlock {
    [LBHTTPClient loadDataWithType:HttpTypePost urlString:@"search.json.php" param:@{@"call":@6} progressBlock:nil SuccedBlock:^(NSURLSessionDataTask *task, id object) {
        dataBlock(object,nil);
    } failureBlock:^(NSURLSessionDataTask *task, NSError *error) {
        dataBlock(nil,error);
    }];
}

#pragma mark
#pragma mark - 搜索返回数据
+ (void)loadSearchPromotionWithBlock:(void (^)(id,NSError *))dataBlock {
    [LBHTTPClient loadDataWithType:HttpTypePost urlString:@"promotion.json.php" param:@{@"call":@8} progressBlock:nil SuccedBlock:^(NSURLSessionDataTask *task, id object) {
        dataBlock(object,nil);
    } failureBlock:^(NSURLSessionDataTask *task, NSError *error) {
        dataBlock(nil,error);
    }];
}

#pragma mark
#pragma mark - 我的订单
+ (void)loadMyOrdersWithBlock:(void (^)(id,NSError *))dataBlock {
    [LBHTTPClient loadDataWithType:HttpTypePost urlString:@"MyOrders.json.php" param:@{@"call":@13} progressBlock:nil SuccedBlock:^(NSURLSessionDataTask *task, id object) {
        dataBlock(object,nil);
    } failureBlock:^(NSURLSessionDataTask *task, NSError *error) {
        dataBlock(nil,error);
    }];
}

#pragma mark
#pragma mark - 我的优惠券
+ (void)loadMyCouponWithBlock:(void (^)(id,NSError *))dataBlock {
    [LBHTTPClient loadDataWithType:HttpTypePost urlString:@"MyCoupon.json.php" param:@{@"call":@9} progressBlock:nil SuccedBlock:^(NSURLSessionDataTask *task, id object) {
        dataBlock(object,nil);
    } failureBlock:^(NSURLSessionDataTask *task, NSError *error) {
        dataBlock(nil,error);
    }];
}

#pragma mark
#pragma mark - 系统消息
+ (void)loadSystemMessageWithBlock:(void (^)(id,NSError *))dataBlock {
    [LBHTTPClient loadDataWithType:HttpTypePost urlString:@"SystemMessage.json.php" param:@{@"call":@10} progressBlock:nil SuccedBlock:^(NSURLSessionDataTask *task, id object) {
        dataBlock(object,nil);
    } failureBlock:^(NSURLSessionDataTask *task, NSError *error) {
        dataBlock(nil,error);
    }];
}

#pragma mark
#pragma mark - 我的消息
+ (void)loadUserMessageWithBlock:(void (^)(id,NSError *))dataBlock {
    [LBHTTPClient loadDataWithType:HttpTypePost urlString:@"UserMessage.json.php" param:@{@"call":@11} progressBlock:nil SuccedBlock:^(NSURLSessionDataTask *task, id object) {
        dataBlock(object,nil);
    } failureBlock:^(NSURLSessionDataTask *task, NSError *error) {
        dataBlock(nil,error);
    }];
}

#pragma mark
#pragma mark - 收货地址
+ (void)loadMyAddressWithBlock:(void (^)(id,NSError *))dataBlock {
    [LBHTTPClient loadDataWithType:HttpTypePost urlString:@"MyAdress.json.php" param:@{@"call":@12} progressBlock:nil SuccedBlock:^(NSURLSessionDataTask *task, id object) {
        dataBlock(object,nil);
    } failureBlock:^(NSURLSessionDataTask *task, NSError *error) {
        dataBlock(nil,error);
    }];
}
@end
